package com.jy.rhin.infra.repo.document.submission.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.jy.rhin.infra.repo.document.submission.po.DocumentAssociationPO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author dhl
 * @date 2022/6/1
 * @Description
 */
@Mapper
@Repository
public interface DocumentAssociationMapper extends BaseMapper<DocumentAssociationPO> {
    /**
     * 列表查询
     * @param queryWrapper
     * @return
     */
    @Select("SELECT DISTINCT a.id,                                                                           \n" +
            "       a.submission_id AS submissionId,                                                         \n" +
            "       a.status_code   AS statusCode,                                                           \n" +
            "       a.type_code     AS typeCode,                                                             \n" +
            "       a.source_id     AS sourceId,                                                             \n" +
            "       a.source_status AS sourceStatus,                                                         \n" +
            "       a.target_id     AS targetId,                                                             \n" +
            "       a.target_status AS targetStatus                                                          \n " +
            "   FROM t_document_association a LEFT JOIN t_document_entry b ON a.submission_id = b.submission_id   \n " +
            "${ew.customSqlSegment}")
    List<DocumentAssociationPO> queryDocumentAssociationListByEntry(@Param(Constants.WRAPPER) QueryWrapper<DocumentAssociationPO> queryWrapper);
}
